package wirepb

import (
	"bytes"
	"io"
)

func (m *BlockHeaderZM) Write(w io.Writer) (int, error) {
	var count int
	n, err := writeBytes(w, m.Mass.Bytes(), m.Zcash.Bytes())
	count += n
	if err != nil {
		return count, err
	}

	return count, err
}

func (m *BlockHeaderZM) Bytes() []byte {
	var buf bytes.Buffer
	m.Write(&buf)
	return buf.Bytes()
}

func (m *BlockHeaderZM) WritePoC(w io.Writer) (int, error) {
	var count int
	n, err := writeBytes(w, m.Mass.BytesPoC(), m.Zcash.Bytes())
	count += n
	if err != nil {
		return count, err
	}

	return count, err
}

func (m *BlockHeaderZM) BytesPoC() []byte {
	var buf bytes.Buffer
	m.WritePoC(&buf)
	return buf.Bytes()
}

func (m *BlockHeaderZM) BytesChainID() []byte {
	var buf bytes.Buffer

	writeBytes(&buf, m.Mass.BytesChainID(), m.Zcash.Bytes())

	return buf.Bytes()
}
